package com.suixun.controller.handle;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.suixun.enums.ApiCode;
import com.suixun.exceptions.SuixunException;
import com.suixun.utils.Constants;

/**
 * 功能描述: session拦截器
 * 
 * @author jacky
 * @date 2018年1月10日上午9:22:04
 */
public class SessionHandle extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
		if (request.getSession().getAttribute(Constants.SESSION_OPERATIONER) == null) {
			throw new SuixunException(ApiCode.HTTP_401);
		}
		return true;
	}
}
